<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>学生管理 - 课堂问答</title>
    <!-- Bootstrap -->
<!--<link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">-->
<!--你自己的样式文件 -->
<link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/base.css" />
<link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/fullpage.css" />
<link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/font-awesome.min.css" />
<!-- <link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/login.css" /> -->
<!-- <link href="css/your-style.css" rel="stylesheet">      -->   
<!-- 以下两个插件用于在IE8以及以下版本浏览器支持HTML5元素和媒体查询，如果不需要用可以移除 -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- 如果要使用Bootstrap的js插件，必须先调入jQuery -->
<!--<script src="http://cdn.bootcss.com/jquery/2.0.0/jquery.js"></script>-->
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/jquery.min.js"></script>
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/fullpage.js"></script>
<!-- 包括所有bootstrap的js插件或者可以根据需要使用的js插件调用　-->
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/bootstrap.min.js"></script>
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/base.js"></script>
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/md5.js"></script>
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/vue.js"></script>
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/Chart.min.js"></script>
    
    <link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/classStuInfo.css" />
    <link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/header.css" />

</head>
<body>
    
    <div id="title">
    <img/>
    <div class="dropdown" id="dropdown">
        <a href="##" data-toggle="dropdown" class="dropdown-toggle">
            <?php echo (session('name')); ?><span class="caret"></span>
        </a>
        <ul class="dropdown-menu pull-right">
            <li ><a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaSettings/info"><span class="glyphicon glyphicon-user"></span> 个人设置</a></li>
            <li class="divider"></li>
            <li ><a href="/root/mynet/5/quizzhku/1/index.php/Home/Auth/logout"><span class="glyphicon glyphicon-log-out"></span> 安全退出</a></li>
        </ul>
    </div>
    <div class="classInfo">
        <h1><?php echo ($classInfo["cla_name"]); ?> - <?php echo ($classInfo["cou_name"]); ?></h1>
        <p>使用以下邀请码邀请学生加课</p>
        <p><?php echo ($classInfo["cla_code"]); ?></p>
        <input type="hidden" id="cla_id" value="<?php echo ($classInfo["cla_id"]); ?>"/>
    </div>
</div>
<div class="navbar navbar-inverse">
    <div class="row">
        <div class="navbar-header col-md-4 ">
            <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-responsive-collapse">
                <span class="sr-only">Toggle Navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classes" class="navbar-brand left">
                <i class="fa fa-long-arrow-left"></i>
                课堂
            </a>
        </div>
        <div class="collapse navbar-collapse navbar-responsive-collapse">
            <div class="col-md-4 ">
                <ul class="nav navbar-nav nav-class">
                    <li <?php if(student == quiz): ?>class="active"<?php endif; ?>><a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaQuiz/quiz?cad=<?php echo ($classInfo["cla_id"]); ?>">测试</a></li>
                    <li <?php if(student == student): ?>class="active"<?php endif; ?>><a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classStuInfo?cad=<?php echo ($classInfo["cla_id"]); ?>">成员</a></li>
                    <li <?php if(student == grade): ?>class="active"<?php endif; ?>><a href="/root/mynet/5/quizzhku/1/index.php/Home/QuizResult/grade?cad=<?php echo ($classInfo["cla_id"]); ?>">成绩</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>

    
    <div class="alert alert-danger hidden" role="alert"></div>
    <div class="alert alert-success hidden" role="alert"></div>
    <div class="container">
        <div class="row" style="margin-bottom: 20px;">
            <div class="col-md-2">
                <button class="btn btn-info exportClassStudent">导出学生名单</button>
            </div>
            <div class="col-md-4">
                学生通过此邀请码加入课堂 : <?php echo ($classInfo["cla_code"]); ?>
            </div>
            <div class="col-md-3 class-number">
                班级人数 : <span><?php echo ($classInfo["cla_stu_num"]); ?></span>
            </div>
            <div class="col-md-2">
                <div class="input-group input-group-sm">
                    <span class="input-group-btn">
                        <button class="btn btn-default search" type="button">
                            <span class="glyphicon glyphicon-search"></span>
                        </button>
                    </span>
                    <input type="text" class="form-control search-input" placeholder="学号 、姓名">
                </div><!-- /input-group -->
            </div>
        </div>
        <div class="row">
            <div class="col-md-2">
                <div class="list-group">
                    <a style="text-align: center;" class="list-group-item">功能</a>
                    <?php if($applyNum != '0'): ?><a href="" class="list-group-item checkApply" data-toggle="modal" data-target="#applyStuModel">
                            查看申请表
                            <span class="badge" id="applyNum"><?php echo ($applyNum); ?></span>
                        </a>
                        <?php else: ?>
                        <a href="javascript:;" class="list-group-item disabled checkApply" title="暂无学生申请">
                            查看申请表
                        </a><?php endif; ?>
                    <a href="" class="list-group-item" data-toggle="modal" data-target="#addStuModel">导入学生</a>
                    <a href="javascript:;" class="list-group-item disabled list-group-item-danger" title="选择学生后才启用" id="removeStu">删除</a>
                </div>
                <form enctype="multipart/form-data" action="/root/mynet/5/quizzhku/1/index.php/Home/ExportExcel/importTxt?cad=<?php echo ($classInfo["cla_id"]); ?>" method="post" target="hidden_frame">
                    <input class="Excelread" type="file" name="file"/>
                    <input type="submit" class="btn btn-primary"/>
                    <iframe name='hidden_frame' id="hidden_frame"></iframe>
                </form>
            </div>
            <!-- 申请表的model-->
            <div class="modal fade" id="applyStuModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title">学生申请表</h4>
                        </div>
                        <div class="modal-body">
                            <table class="table table-hover apply_table">
                                <tr>
                                    <th><input type="checkbox"/></th>
                                    <th>学生学号</th>
                                    <th>学生姓名</th>
                                    <th>操作</th>
                                </tr>
                                <?php if(is_array($applyStu)): $i = 0; $__LIST__ = $applyStu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$stu): $mod = ($i % 2 );++$i;?><tr>
                                        <td><input type="checkbox" value="<?php echo ($stu["stu_id"]); ?>"/></td>
                                        <td><?php echo ($stu["stu_number"]); ?></td>
                                        <td><?php echo ($stu["stu_name"]); ?></td>
                                        <td>
                                            <div class="fill_in">
                                                <span class="glyphicon glyphicon-option-horizontal"></span>
                                            </div>
                                            <div class="os_btn">
                                                <span class="glyphicon glyphicon-remove removeApply" value="<?php echo ($stu["stu_id"]); ?>" title="删除申请"></span>
                                            </div>
                                        </td>
                                    </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                            </table>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-primary btn_allowApply disabled">提交</button>
                            <button type="button" class="btn btn-danger removeMoreApply disabled">删除</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 导入学生的model-->
            <div class="modal fade" id="addStuModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title">导入学生</h4>
                        </div>
                        <div class="modal-body">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="input-group">
                                        <input type="text" class="form-control" placeholder="学号">
                                        <span class="input-group-btn">
                                            <button class="btn btn-default" type="button">
                                                <span class="glyphicon glyphicon-search applySearch"></span>
                                            </button>
                                        </span>
                                    </div><!-- /input-group -->
                                </div>
                                <div class="col-md-6">
                                    <select class="form-control ">
                                        <option class="selected" value="">请选择导入班级</option>
                                        <?php if(is_array($allClass)): $i = 0; $__LIST__ = $allClass;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$cla): $mod = ($i % 2 );++$i;?><option value="<?php echo ($cla["cla_id"]); ?>"><?php echo ($cla["cou_name"]); ?> - <?php echo ($cla["cla_name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                                    </select>
                                </div>
                            </div>
                            <br/>
                            <div class="row" id="content">
                                <table class="table table-hover">
                                    <tr>
                                        <th><input type="checkbox"/> </th>
                                        <th>学生学号</th>
                                        <th>学生姓名</th>
                                    </tr>
                                </table>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-primary btn_addStu disabled">提交</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal fade bs-example-modal-s" id="deleteTip" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog modal-sm" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title text-danger" id="myModalLabel">删除警告</h4>
                        </div>
                        <div class="modal-body">
                            确定要删除 <span class="text-info deletename" style="font-size:18px;"></span> 吗?<br/>
                            该学生将无法参与该班级的测试
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-danger sure-delete">确定</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        </div>
                    </div>
                </div>
            </div>
            <!-- .....-->
            <div class="col-md-9">
                <?php if($student != null): ?><table class="table table-hover stuInfo_table">
                        <tr class="table-header">
                            <th><input type="checkbox"/> </th>
                            <th>学号</th>
                            <th>姓名</th>
                            <th>邮箱</th>
                            <th>操作</th>
                        </tr>
                        <?php if(is_array($student)): $i = 0; $__LIST__ = $student;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$stu): $mod = ($i % 2 );++$i;?><tr value="<?php echo ($stu["stu_id"]); ?>">
                                <td><input type="checkbox" value="<?php echo ($stu["stu_id"]); ?>" onclick="stuInfoSingleSelect()"/></td>
                                <td><?php echo ($stu["stu_number"]); ?></td>
                                <td><?php echo ($stu["stu_name"]); ?></td>
                                <td><?php echo ($stu["stu_email"]); ?></td>
                                <td>
                                    <div class="fill_in">
                                        <span class="glyphicon glyphicon-option-horizontal"></span>
                                    </div>
                                    <div class="os_btn">
                                        <span class="glyphicon glyphicon-remove removeStu" onclick="singleDelete('<?php echo ($stu["stu_id"]); ?>','<?php echo ($stu["stu_name"]); ?>')" title="移除学生" ></span>
                                    </div>
                                </td>
                            </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                    </table>
                    <?php else: ?>
                    <div class="no_stu">
                        <p>本班级暂时没有学生加入</p>
                        <p>让学生使用以下代码加入课堂 ：<?php echo ($classInfo["cla_code"]); ?></p>
                    </div><?php endif; ?>
            </div>
        </div>



        <div class="row">
            <div class="col-md-5 col-md-offset-5">
                <nav>
                    <ul class="pagination">
                        <?php if($pageInfo['page']-1 > 0): ?><!-- 首页-->
                            <li>
                                <a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classStuInfo?cad=<?php echo ($classInfo['cla_id']); ?>&amp;np=1">
                                    <span aria-hidden="true">&laquo;首页</span>
                                </a>
                            </li>
                            <!--上一页>
                            <li>
                                <a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classStuInfo?cd=<?php echo ($course['cou_id']); ?>&amp;cad=<?php echo ($classInfo['cla_id']); ?>&amp;np=<?php echo ($pageInfo['np']-1); ?>">
                                    <span aria-hidden="true">UP</span>
                                </a>
                            </li-->
                            <!--页数-->
                            <!--1-->
                            <?php if($pageInfo['np']-2 > 0): ?><li><a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classStuInfo?cad=<?php echo ($classInfo['cla_id']); ?>&amp;np=<?php echo ($pageInfo['np']-2); ?>"><?php echo ($pageInfo['np']-2); ?></a></li><?php endif; ?>
                            <!--2-->
                            <?php if($pageInfo['np']-1 > 0): ?><li><a  href="/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classStuInfo?cad=<?php echo ($classInfo['cla_id']); ?>&amp;np=<?php echo ($pageInfo['np']-1); ?>"><?php echo ($pageInfo['np']-1); ?></a></li><?php endif; ?>
                            <!--当前页数-->
                            <li class="active"><a  href="/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classStuInfo?cad=<?php echo ($classInfo['cla_id']); ?>&amp;np=<?php echo ($pageInfo['np']); ?>"><?php echo ($pageInfo["np"]); ?></a></li>
                            <!--4-->
                            <?php if($pageInfo['np']+1 <= $pageInfo['page']): ?><li><a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classStuInfo?cad=<?php echo ($classInfo['cla_id']); ?>&amp;np=<?php echo ($pageInfo['np']+1); ?>"><?php echo ($pageInfo['np']+1); ?></a></li><?php endif; ?>
                            <!--5-->
                            <?php if($pageInfo['np']+2 <= $pageInfo['page']): ?><li><a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classStuInfo?cad=<?php echo ($classInfo['cla_id']); ?>&amp;np=<?php echo ($pageInfo['np']+2); ?>"><?php echo ($pageInfo['np']+2); ?></a></li><?php endif; ?>
                            <!--下一页-->
                            <!--if condition="$pageInfo['np']+1 elt $pageInfo['page']">
                            <li>
                                <a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classStuInfo?cd=<?php echo ($course['cou_id']); ?>&amp;cad=<?php echo ($classInfo['cla_id']); ?>&amp;np=<?php echo ($pageInfo['np']+1); ?>">
                                    <span aria-hidden="true">Down</span>
                                </a>
                            </li-->
                            <!--末页-->
                            <li>
                                <a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classStuInfo?cad=<?php echo ($classInfo['cla_id']); ?>&amp;np=<?php echo ($pageInfo['page']); ?>">
                                    <span aria-hidden="true">尾页&raquo;</span>
                                </a>
                            </li><?php endif; ?>
                    </ul>
                </nav>
            </div>
        </div>
    </div>
    <script>
        $(function(){
            var obj_cla_id = $("#cla_id");
            //背景的设置
            var bg = obj_cla_id.val() % 5 + 1;
            $("#title img").prop("src","/root/mynet/5/quizzhku/1/Public/Images/" + bg + ".jpg");
            //班级基本信息的显示
            $(".classInfo").css("opacity","1");
            //操作按钮的隐藏
            $(".os_btn").hide();
            //操作按钮的显示/隐藏
            $(".table tr:has(td)").on("hover",hover());
            var delete_btn = $("#removeStu");
            //学生基本信息的复选框全选的功能绑定
            $(".stuInfo_table tr th input").on("click",stuInfoAllSelect());
            //群删除功能
            delete_btn.click(function(){
                if(!$(this).hasClass("disabled")) {
                    $('#deleteTip').modal('show');
                    $('#deleteTip .modal-body .deletename').text("选择的学生");
                    $(".sure-delete").click(function () {
                        if (!delete_btn.hasClass("disabled")) {
                            var stu_id = new Array();
                            $.each($(".stuInfo_table tr td input:checked"), function () {
                                stu_id.push($(this).val());
                            });
                            $.ajax({
                                url: "/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/removeStu",
                                type: "post",
                                data: {student_stu_id: stu_id, class_cla_id: obj_cla_id.val()},
                                success: function (data) {
                                    if (data.status == 1) {
                                        showSuccessReload("删除成功!");
                                        $('#deleteTip').modal('hide');
                                    }
                                    else {
                                        showError(data.message);
                                    }
                                }
                            });
                        }
                    });
                }
            });
            //申请学生的复选框功能
            var applyStu_allSelect = $(".apply_table tr th input");
            var applyStu_stuCheck = $(".apply_table tr td input");
            var applyStu_lenght = applyStu_stuCheck.length;
            applyStu_allSelect.click(function(){
                $.each(applyStu_stuCheck,function(){
                    $(this).prop("checked",applyStu_allSelect.is(":checked"));
                });
                if(applyStu_allSelect.is(":checked")){
                    $(".btn_allowApply").removeClass("disabled");
                    $(".removeMoreApply").removeClass("disabled");
                }
                else{
                    $(".btn_allowApply").addClass("disabled");
                    $(".removeMoreApply").addClass("disabled");
                }
            });
            applyStu_stuCheck.click(function(){
                var checkedBox_length = $(".apply_table tr td input:checked").length;
                if(checkedBox_length !=0){
                    $(".btn_allowApply").removeClass("disabled");
                    $(".removeMoreApply").removeClass("disabled");
                }
                else{
                    $(".btn_allowApply").addClass("disabled");
                    $(".removeMoreApply").addClass("disabled");
                }
                if(checkedBox_length==applyStu_lenght){
                    applyStu_allSelect.prop("checked",true);
                }
                else{
                    applyStu_allSelect.prop("checked",false);
                }
            });
            //批量通过申请的功能
            var btn_allowApply = $(".btn_allowApply");
            btn_allowApply.click(function(){
                if(!btn_allowApply.hasClass("disabled")) {
                    var stu_id = new Array();
                    $.each($(".apply_table tr td input:checked"), function () {
                        stu_id.push($(this).val());
                    });
                    $.ajax({
                        url: "/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/allowStuJoin",
                        type: "post",
                        data: {student_stu_id: stu_id, class_cla_id: obj_cla_id.val()},
                        success: function (data) {
                            if (data.status == 1) {
                                $('#applyStuModel').modal('hide');
                                showSuccessReload("学生申请成功!");
                            }
                            else {
                                showError(data.message);
                            }
                        }
                    });
                }
            });
            //单个删除申请的功能
            $(".removeApply").click(function(){
                var self = $(this);
                $('#deleteTip').modal('show');
                $('#deleteTip .modal-body .deletename').text("学生的申请");
                $(".sure-delete").click(function() {
                    var stu_id = $(".removeApply").attr("value");
                    var parent_tr = self.parent().parent().parent("tr");
                    $.ajax({
                        url: "/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/removeApply",
                        type: "post",
                        data: {student_stu_id: stu_id, class_cla_id: obj_cla_id.val()},
                        success: function (data) {
                            if (data.status == 1) {
                                parent_tr.fadeOut(500, function () {
                                    $(this).remove();
                                });
                                var num = $("#applyNum").text() - 1;
                                if (num != 0) {
                                    $("#applyNum").text(num);
                                }
                                else {
                                    $('#applyStuModel').modal('hide');
                                    setTimeout("location.reload();", 200);
                                }
                                $('#deleteTip').modal('hide');
                                showSuccess("删除学生申请成功!");
                            }
                            else {
                                showError(data.message);
                            }
                        }
                    });
                });
            });
            //多个删除申请的功能
            var removeMoreApply = $(".removeMoreApply");
            removeMoreApply.click(function(){
                if(!removeMoreApply.hasClass("disabled")) {
                    $('#deleteTip').modal('show');
                    $('#deleteTip .modal-body .deletename').text("选中学生的申请");
                    $(".sure-delete").click(function() {
                        var stu_id = new Array();
                        var checkBox = $(".apply_table tr td input:checked");
                        $.each(checkBox, function () {
                            stu_id.push($(this).val());
                        });
                        $.ajax({
                            url: "/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/removeApply",
                            type: "post",
                            data: {student_stu_id: stu_id,class_cla_id: obj_cla_id.val()},
                            success: function (data) {
                                if (data.status == 1) {
                                    $.each(checkBox, function () {
                                        $(this).parent().parent("tr").fadeOut(500, function () {
                                            $(this).remove();
                                        });
                                    });
                                    var num = $("#applyNum").text() - checkBox.length;
                                    if (num != 0) {
                                        $("#applyNum").text(num);
                                    }
                                    else {
                                        $('#applyStuModel').modal('hide');
                                        $("#applyNum").remove();
                                        $(".checkApply").addClass("disabled")
                                        $(".checkApply").removeAttr("data-toggle", "data-target");
                                        $(".checkApply").attr("href", "javascript:;");
                                        $(".checkApply").attr("title", "暂时无学生申请");
                                    }
                                    $('#deleteTip').modal('hide');
                                    showSuccess("删除学生申请成功!");
                                }
                                else {
                                    showError(data.message);
                                }
                            }
                        });
                    });
                }
            });
            //导入学生的全选按钮的实现
            var import_allSelect = $("#addStuModel .table tr th input");
            import_allSelect.click(function(){
                var import_stuCheck = $("#addStuModel .modal-body .table tr td input");
                if(import_allSelect.is(":checked")){
                    $("#addStuModel .btn_addStu").removeClass("disabled");
                }
                else{
                    $("#addStuModel .btn_addStu").addClass("disabled");
                }
                $.each(import_stuCheck,function(){
                    $(this).prop("checked",import_allSelect.is(":checked"));
                });
            });
            //按照学号查询某个学生(导入学生功能中的)
            $("#addStuModel .modal-body button").click(function(){
                import_allSelect.prop("checked",false);
                $("#addStuModel .btn_addStu").addClass("disabled");
                var stu_number = $("#addStuModel .modal-body input").val();
                if(stu_number!=""){
                    $.ajax({
                        url:"/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/getStuInfo",
                        type:"post",
                        data:{stu_number:stu_number,class_cla_id:obj_cla_id.val()},
                        success:function(data){
                            $("#addStuModel .modal-body #content .table tr:has(td)").empty();
                            if(data.status == 1){
                                var html = "<tr><td><input type='checkbox' onclick='check(this)' value='"+data.data.stu_id+"'/></td><td>"+data.data.stu_number+"</td><td>"+data.data.stu_name+"</td></tr>";
                                $("#addStuModel .modal-body #content .table").append(html);
                            }
                            else{
                                $("#addStuModel .modal-body #content .table").append("<tr><td colspan='3' class='text-center'>查无此人,请查证学号是否正确!</td></tr>");
                            }
                        }
                    });
                }
            });
            //按班级导入学生
            $("#addStuModel .modal-body select").change(function(){
                import_allSelect.prop("checked",false);
                $("#addStuModel .btn_addStu").addClass("disabled");
                var check_cla_id = ($("#addStuModel .modal-body select option:selected").val());
                if(check_cla_id != ""){
                    $.ajax({
                        url:"/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/getClassStu",
                        type:"post",
                        data:{check_cla_id:check_cla_id,class_cla_id:obj_cla_id.val()},
                        success:function(data){
                            $("#addStuModel .modal-body #content .table tr:has(td)").empty();
                            if(data.data!=""){
                                for(var i = 0;i<data.data.length;i++) {
                                    var html = "<tr><td><input type='checkbox' onclick='check(this)' value='" + data.data[i].stu_id + "'/></td><td>" + data.data[i].stu_number + "</td><td>" + data.data[i].stu_name + "</td></tr>";
                                    $("#addStuModel .modal-body #content .table").append(html);
                                }
                            }
                            else{
                                $("#addStuModel .modal-body #content .table").append("<tr><td colspan='3' class='text-center'>该班级暂时无可添加的学生!</td></tr>");
                            }
                        }
                    });
                }
                else{
                    $("#addStuModel .modal-body #content .table tr:has(td)").empty();
                }
            });
            //查询到学生后把学生添加到班级中的功能
            $("#addStuModel .btn_addStu").click(function(){
                if(!$(this).hasClass("disabled")){
                    var stu_id = new Array();
                    $.each($("#addStuModel .modal-body .table tr td input:checked"),function(){
                        stu_id.push($(this).val());
                    });
                    $.ajax({
                        url:"/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/importStu",
                        type:"post",
                        data:{class_cla_id:obj_cla_id.val(),stu_id:stu_id},
                        success:function(data){
                            if(data.status==1){
                                //成功导入的信息已经放在data中
                                $('#addStuModel').modal('hide');
                                showSuccessReload("成功导入学生"+data.data.success+"个!");
                            }
                            else{
                                showError("导入学生失败,学生已在本班级!");
                            }
                        }
                    });
                }
            });
            //班级学生的查询功能
            $(".search").click(function(){
                $(".stuInfo_table tr th input").prop("checked",false);
                $("#removeStu").addClass("disabled");
                var keyword = $(".search-input").val();
                $.ajax({
                    url:"/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/searchStu",
                    type:"post",
                    data:{class_cla_id:obj_cla_id.val(),keyword:keyword},
                    success:function(data){
                        $(".stuInfo_table tr:has(td)").remove();
                        if(data!=""){
                            for(var i = 0;i<data.length;i++) {
                                var html = "<tr value='" + data[i].stu_id + "'><td><input type='checkbox' onclick='stuInfoSingleSelect()' value='" + data[i].stu_id + "'/></td><td>" + data[i].stu_number + "</td><td>" + data[i].stu_name + "</td><td>"+data[i].stu_email+"</td><td> <div class='fill_in'> <span class='glyphicon glyphicon-option-horizontal'></span> <span class='glyphicon glyphicon-option-horizontal'></span> </div> <div class='os_btn'> <span class='glyphicon glyphicon-search search' title='查询详情'></span> <span class='glyphicon glyphicon-remove removeStu' onclick=singleDelete("+data[i].stu_id+",'"+data[i].stu_name+"') title='移除学生'></span></div></td></tr>";
                                $(".stuInfo_table").append(html);
                            }
                            $(".table tr:has(td)").on("hover",hover());
                            $(".table tr:has(td) .os_btn").hide();
                        }
                    }
                });
            });
            //打印学生名单
            $(".exportClassStudent").click(function(){
                window.open("/root/mynet/5/quizzhku/1/index.php/Home/ExportExcel/exportClassStudent?cad="+obj_cla_id.val());
            });
            //导入学生名单
//            $(".readExcel").click(function(){
//                window.open("/root/mynet/5/quizzhku/1/index.php/Home/ExportExcel/readExcel");
//            });
        });
        //导入学生功能中的添加按钮的变化
        function check(checkbox){
            var checkNum = $("#addStuModel .modal-body #content .table td input:checked").length;
            var allNum = $("#addStuModel .modal-body #content .table td input").length;
            if(checkNum != 0){
                $("#addStuModel .btn_addStu").removeClass("disabled");
                if(checkNum == allNum){
                    $("#addStuModel .table tr th input").prop("checked",true);
                }
                else{
                    $("#addStuModel .table tr th input").prop("checked",false);
                }
            }
            else{
                $("#addStuModel .btn_addStu").addClass("disabled");
            }
        }
        //学生基本信息的操作按钮的显示与隐藏
        function hover() {
            $(".table tr:has(td)").hover(
                    function () {
                        $(this).find(".os_btn").show();
                        $(this).find(".fill_in").hide();
                    },
                    function () {
                        $(this).find(".os_btn").hide();
                        $(this).find(".fill_in").show();
                    });
        }
        //学生基本信息的复选按钮的控制(全选)
        function stuInfoAllSelect(){
            var allSelect = $(".stuInfo_table tr th input");
            allSelect.click(function() {
                var stuInfo_stuCheck =  $(".stuInfo_table tr td input");
                if ($(this).is(":checked")) {
                    $("#removeStu").removeClass("disabled");
                }
                else {
                    $("#removeStu").addClass("disabled");
                }
                $.each(stuInfo_stuCheck, function () {
                    $(this).prop("checked",  allSelect.is(":checked"));
                });
            });
        }
        //学生基本信息的复选按钮的控制(单选)
        function stuInfoSingleSelect(){
            var stuInfo_allSelect = $(".stuInfo_table tr th input");
            var stuInfo_stuCheck = $(".stuInfo_table tr td input");
            var stuInfo_length = stuInfo_stuCheck.length;
            var checkedBox_length = $(".stuInfo_table tr td input:checked").length;
            if(checkedBox_length==0){
                $("#removeStu").addClass("disabled");
            }
            else{
                if(checkedBox_length==stuInfo_length){
                    stuInfo_allSelect.prop("checked",true);
                }
                else{
                    stuInfo_allSelect.prop("checked",false);
                }
                $("#removeStu").removeClass("disabled");
            }
        }
        //单个删除功能
        function singleDelete(id,name){
            $('#deleteTip').modal('show');
            $('#deleteTip .modal-body .deletename').text(name);
            $(".sure-delete").click(function(){
                var stu_id = id;
                var cla_id = $("#cla_id").val();
                var parent_tr =$(".stuInfo_table tr[value='"+stu_id+"']");
                $.ajax({
                    url:"/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/removeStu",
                    type:"post",
                    data:{student_stu_id:stu_id,class_cla_id:cla_id},
                    success:function(data){
                        if(data.status == 1){
                            parent_tr.fadeOut(500,function(){$(this).remove();});
                            showSuccess(data.message);
                            $(".class-number span").text(data.data);
                            $('#deleteTip').modal('hide');
                        }
                        else{
                            showError(data.message);
                        }
                    }
                });
            });
        }
    </script>

</body>